#include #include #include #include using namespace std; struct Food { string id; string groupID; string longDescription; string shortDescription; string commonName; string manufacName; string survey; string inedibleParts; string percentageRefuse; string scientificName; string nitrogenFactor; string proteinFactor; string fatFactor; string carbohydrateFactor; void display() { cout << "id: " << id << endl; cout << "groupID: " << groupID << endl; cout << "longDescription: " << longDescription << endl; cout << "shortDescription: " << shortDescription << endl; cout << "commonName: " << commonName << endl; cout << "manufacName: " << manufacName << endl; cout << "survey: " << survey << endl; cout << "inedibleParts: " << inedibleParts << endl; cout << "percentageRefuse: " << percentageRefuse << endl; cout << "scientificName: " << scientificName << endl; cout << "nitrogenFactor: " << nitrogenFactor << endl; cout << "proteinFactor: " << proteinFactor << endl; cout << "fatFactor: " << fatFactor << endl; cout << "carbohydrateFactor: " << carbohydrateFactor << endl; } }; void main() { vector foods; ifstream fin(".\\USDA\\Food_Des.txt"); while(!fin.eof()) { Food newFood; //read from the file getline(fin,newFood.id,'^'); getline(fin,newFood.groupID,'^'); getline(fin,newFood.longDescription,'^'); getline(fin,newFood.shortDescription,'^'); getline(fin,newFood.commonName,'^'); getline(fin,newFood.manufacName,'^'); getline(fin,newFood.survey,'^'); getline(fin,newFood.inedibleParts,'^'); getline(fin,newFood.percentageRefuse,'^'); getline(fin,newFood.scientificName,'^'); getline(fin,newFood.nitrogenFactor,'^'); getline(fin,newFood.proteinFactor,'^'); getline(fin,newFood.fatFactor,'^'); getline(fin,newFood.carbohydrateFactor); foods.push_back(newFood); } fin.close(); char menuOption; do { cout << "View\n"; cout << "eXit\n"; cout << ">"; cin >> menuOption; string description; if(menuOption == 'V') { cout << "Food to find? "; cin >> description; for(int i = 0; i < foods.size(); i++) { if(foods[i].longDescription.find(description) != string::npos) { //display the food foods[i].display(); } } } } while(menuOption != 'X'); }